from rest_framework.filters import BaseFilterBackend
from user.models import Doctor


class MyFilter(BaseFilterBackend):
    def filter_queryset(self, request, queryset, view):
        name = request.query_params.get('name',None)
        if name:
            doctor = Doctor.objects.filter(name=name).first()
            pk = doctor.id
            queryset = queryset.filter(doctor=pk)
        return queryset